{{
for _k,_file in enumerate(response.files or []):
  if _file in response.files[:_k]:
     continue
  elif _file[-4:].lower()=='.css':}}
     <link href="{{=_file}}" rel="stylesheet" type="text/css" charset="utf-8" />{{
  elif _file[-3:].lower()=='.js':}}
     <script src="{{=_file}}" type="text/javascript"></script>{{
  else:}}
    {{=XML(_file)}}
  {{
  pass
pass
}}
<script>
function ajax(u,s,t) {
  var query="";
  for(i=0; i<s.length; i++) { 
     if(i>0){
      query=query+"&";
      }
     query=query+encodeURIComponent(s[i])+"="+encodeURIComponent(document.getElementById(s[i]).value);
  }
  jQuery.ajax({type: "POST", url: u, data: query, success: function(msg) { if(t==':eval') eval(msg); else document.getElementById(t).innerHTML=msg; } });  
}
function web2py_trap_form(action,target) {
   jQuery('#'+target+' form').each(function(i){
      var form=jQuery(this);
      jQuery('input[type="submit"]',this).click(function(){
         jQuery('.flash').hide().html('');
         web2py_ajax_page('post',action,form.serialize(),target);
         return false;
      });
   });
}
function web2py_ajax_page(method,action,data,target) {
  jQuery.ajax({'type':method,'url':action,'data':data,
    'beforeSend':function(xhr){
      xhr.setRequestHeader('web2py-component-location',document.location);
      xhr.setRequestHeader('web2py-component-element',target);},
    'complete':function(xhr,text){
      command=xhr.getResponseHeader('web2py-component-command');
      if(command) eval(command);
      flash=xhr.getResponseHeader('web2py-component-flash');
      if(flash) jQuery('.flash').html(flash).slideDown();
      },
    'success': function(text) {
      jQuery('#'+target).html(text);
      web2py_trap_form(action,target);
      web2py_ajax_init();
      }
    });
}
function web2py_component(action,target) {
    jQuery(document).ready(function(){ web2py_ajax_page('get',action,null,target); });
}
</script>
